import { RouteRecordRaw } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import NotAuthView from '@/views/NotAuth.vue'
import OnlyAmdinView from '@/views/OnlyAmdin.vue'
import HiddenView from '@/views/HiddenView.vue'
import ACCESS_ENUM from '@/access/accessEnum'
import UserLoginView from '@/views/user/UserLoginView.vue'
import UserRegisterView from '@/views/user/UserRegisterView.vue'
import UserLayout from '../layouts/UserLayout.vue'
import AddQuestionView from '@/views/question/AddQuestionView.vue'
import ManagerQuestionView from '@/views/question/ManagerQuestionView.vue'
import QuestionView from '@/views/question/QuestionView.vue'
import ViewQuestionView from '@/views/question/ViewQuestionView.vue'
import QuestionDetail from '@/views/question/QuestionDetail.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/user',
    name: '用户',
    component: UserLayout,
    meta: {
      hideInMenu: true
    },
    children: [
      {
        path: '/user/login',
        name: '用户登录',
        component: UserLoginView
      },
      {
        path: '/user/register',
        name: '用户注册',
        component: UserRegisterView
      }
    ]
  },
  {
    path: '/add/question',
    name: '创建题目',
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN
    }
  },
  {
    path: '/update/question',
    name: '更新题目',
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true
    }
  },
  {
    path: '/manage/question/',
    name: '管理题目',
    component: ManagerQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN
    }
  },
  {
    path: '/view/question/:id',
    name: '做题目',
    component: ViewQuestionView,
    props: true,
    meta: {
      // access: ACCESS_ENUM.ADMIN
      hideInMenu: true
    }
  },
  {
    path: '/',
    name: '浏览题目',
    component: QuestionView
  },
  {
    path: '/question/detail',
    name: '答题详情',
    component: QuestionDetail,
    meta: {
      access: ACCESS_ENUM.USER
    }
  },
  {
    path: '/admin',
    name: '管理员',
    component: OnlyAmdinView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true
    }
  },
  {
    path: '/notAuth',
    name: '无权限',
    component: NotAuthView,
    meta: {
      hideInMenu: true
    }
  },
  {
    path: '/about',
    name: '关于我们',
    component: () =>
      import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

export default routes
